<?php

namespace app\admin\model;

use app\common\model\BaseModel;


class ResumeBase extends BaseModel
{

    

    

    // 表名
    protected $name = 'resume_base';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'sex_text',
        'job_class_id_text'
    ];
    


    public function resumejob(){
        return $this->hasMany("ResumeJob","resume_base_id","id");
    }

    public function resumeedu(){
        return $this->hasMany("ResumeEdu","resume_base_id","id");
    }

    public function resumecontent(){
        return $this->hasOne("ResumeContent","resume_base_id","id");
    }
    
    public function getSexList()
    {
        return ['0' => __('Sex 0'), '1' => __('Sex 1'), '2' => __('Sex 2')];
    }


    public function getSexTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['sex']) ? $data['sex'] : '');
        $list = $this->getSexList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getJobClassIdTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['job_class_id']) ? $data['job_class_id'] : '');
        $value = JobClass::where("id",$value)->value("name");
        return $value;
    }




}
